//02-cals.js
const math = require('mathjs');

const args = process.argv.slice(2);

if (args.includes('--help') || args.includes('-h')) {
  console.log('Usage: node 02-calc.js <expression>');
  process.exit(0);
}

if (args.length === 0) {
  console.log('Usage: node 02-calc.js <expression>');
  process.exit(0);
} else if (args.length > 3) {
  console.log('Too many arguments.');
  process.exit(0);
}

const expression = args[0];
try {
  const result = math.evaluate(expression);
  console.log(`Result: ${result}`);
} catch (error) {
  console.log('Error');
}